home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / RCShaders / RCRubber.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  583 b   |  24 lines

  1. /* Listing 16.38  Rubber surface shader*/
  2.  
  3. /*
  4.  * rubber(): This shader generates a rubber surface. It is a matte shader that
  5.  * adds in a little white dust to mimic the dust on a new eraser.
  6.  */
  7. surface
  8. RCRubber( 
  9.     float    Ka        = 1.0, 
  10.         Kd        = 1.0, 
  11.         txtscale    = 1.5 )
  12. {
  13.     point    Nf = faceforward(normalize(N),I), 
  14.         Ploc = transform("shader", P);  /* Move to shader space */
  15.     color    cout, white=1;
  16.  
  17.     /* Mix in some white dust. */
  18.     cout = mix(Cs, white, .05* (float noise(txtscale*Ploc)));
  19.  
  20.     /* Compute a matte surface. */
  21.     Oi = Os;
  22.     Ci = Os * cout * ( Ka*ambient() + Kd*diffuse(Nf) ) ;
  23. }
  24.